package com.wjn.basic.thread.AqsDemo.RLock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * AQS
 * ReentantLock
 * CountDownLatch
 * CyclicBarrier
 * Semaphore
 * Exchanger
 * Worker  (ThreadPollExcutor类中)
 */
public class ReentantLockDemo {

    public ReentantLockDemo(){

    }
    //该锁默认为非公平锁
    ReentrantLock lock=new ReentrantLock();

    public void synchronizeMethod(){
        lock.lock();
        for (int i=0;i<5;i++) {
            System.out.println(Thread.currentThread().getName()+(" "+i+1));
        }
        lock.unlock();

    }

    public static void main(String[] args) {
        ReentantLockDemo lockDemo=new ReentantLockDemo();
        ThreadDemo a1=new ThreadDemo(lockDemo);a1.start();
        ThreadDemo a2=new ThreadDemo(lockDemo);a2.start();
        ThreadDemo a3=new ThreadDemo(lockDemo);a3.start();
        ThreadDemo a4=new ThreadDemo(lockDemo);a4.start();
        ThreadDemo a5=new ThreadDemo(lockDemo);a5.start();

    }




}
